from common.exception.base_exception import BaseBizException
from common.exception.biz_error_type import BizErrorType

"""
业务异常

Copyright (C) chengpeng.hu. All Rights Reserved

@Author : chengpeng.hu
@Date : 2024
"""


class BizException(BaseBizException):
    def __init__(self, biz_error_type: BizErrorType, cause=None):
        super().__init__(biz_error_type, biz_error_type.msg, cause)

    @classmethod
    def from_error_code(cls, biz_error_type: BizErrorType, msg: str = None):
        if msg is not None:
            biz_error_type.msg = msg
        return cls(biz_error_type)
